#ifndef _FAIR_SCHED_H
#define _FAIR_SCHED_H
#include <stdlib.h>
#include <stdio.h>

#include "process.h"
/*
 * Created by Sam
 * 3/27/11
 */


/*
 * Data Types 
 */

/*
 * Group: holds the definition for how many groups (or bundles) are currently, 
 * being used, along with pointers to the next/prev bundle. 
 */
struct group
{
    int size; //size of the bunlde  
    int gid; //group id 

    int time_quantum;

    struct process_struct * bundle;
    
    struct group * next;
    struct group * prev;
};

struct group * groups         = NULL;
struct group * empty_groups   = NULL; //holds all the unused groups  
int            n_groups       = 0;
int            n_empty_groups = 0;

/*
 * Init Groups
 */

int 
setup_groups(int number);

/*
 * Group Functions
 */
struct group *
dequeue_group(struct group ** dequeue);

struct group *
enqueue_group(struct group ** enqueue, struct group * insert);

/*
 * Process Functions
 */

int 
add_to_group( struct process_struct * insert, int gid);

struct process_struct *
remove_from_group(int pid);

/*
 * Bundle Functions
 *
 * uses queue.h to perform enqueue and dequeue
 */
struct process_struct *
dequeue_bundle(struct process_struct ** queue, int * size);

struct process_struct *
enqueue_bundle(struct process_struct ** queue, struct process_struct * insert, int * size);

/*
 * Stats 
 */

int 
group_stats();
#endif
